﻿@model SuperiorModel.ShopAppModel
@{
    ViewBag.Title = "版本信息";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var lasterVersion = Redis.RedisManager.GetLasterItemFromList<SuperiorModel.VersionItem>("Version");
    var _serverAppID = SuperiorCommon.ConfigSettings.Instance.ServerAppID;
    var _redirect_uri = SuperiorCommon.ConfigSettings.Instance.ServeAuthRedirectUri;
    var _pre_auth_code = ViewBagManager.GetPre_auth_code(Request["id"]);
    var checkInfo = Redis.RedisManager.Get<SuperiorModel.ShopAppCheckInfo>("CheckInfo_" + Request["id"]);
}
<input type="hidden" id="mapRotute" map="map_shopapp" />
<style>
    /*控制文本框长度*/
</style>
<div class="title_ding">

    <p id="location">
        当前位置：
        版本信息
    </p>
</div>
<input type="hidden" value="@ViewBag.Msg" id="hidden_msg"/>
<div class="layui">
    <div class="shopmain">
        <div class="layui-card">
            <div class="layui-card-header">版本信息</div>
            <div class="layui-card-body">
                <blockquote class="layui-elem-quote layui-quote-nm">注：更新版本到微信小程序流程,<b>请严格按照步骤执行</b>：</br>1.点击《更新并上传》</br>2.成功后点击《体验小程序》</br>3.没问题点击《提交微信审核》</br>4.点击《获取审核结果》</br>5.审核通过点击《发布小程序》</blockquote>
                <div class="layui-form" action="">
                    <div class="layui-form-item">
                        <label for="text_shopname" class="layui-form-label">
                            商城名称
                        </label>
                        <div class="layui-input-inline" style="width:50%">
                            <input type="text" id="text_shopname" name="text_shopname" lay-verify="required" class="layui-input" disabled="disabled" value="@Model.ShopName" placeholder="请输入商城名称">
                        </div>
                       
                    </div>

                    <div class="layui-form-item">
                        <label for="text_appid" class="layui-form-label">
                            小程序AppID
                        </label>
                        <div class="layui-input-inline" style="width:50%">
                            <input type="text" id="text_appid" name="text_appid" lay-verify="required" class="layui-input" disabled="disabled" value="@Model.AppId" placeholder="请输入小程序AppID">
                        </div>
                       
                    </div>
                    <div class="layui-form-item">
                        <label for="" class="layui-form-label">
                            当前版本号
                        </label>
                        <div class="layui-input-inline" style="width:50%">
                            <input type="text"  lay-verify="required" class="layui-input" disabled="disabled" value="@Model.Version" placeholder="">
                        </div>
                        
                    </div>
                    <div class="layui-form-item">
                        <label for="" class="layui-form-label">
                            最新版本号
                        </label>
                        <div class="layui-input-inline" style="width:50%">
                            <input type="text" lay-verify="required" class="layui-input" disabled="disabled" value="@lasterVersion.Version" placeholder="">
                        </div>

                    </div>
                   
                    @if (Model.Version != lasterVersion.Version)
                    {

                        if (checkInfo != null)
                        {
                            <div class="layui-form-item">
                                <label for="" class="layui-form-label">
                                    最近一次审核信息:
                                </label>
                                @if (checkInfo.Status == 2)
                                {
                                    <div class="layui-input-block" style="margin:0;">
                                        审核时间:@checkInfo.UpdateTime,审核失败原因:@checkInfo.ErrorMsg

                                    </div>
                                }
                                else if (checkInfo.Status == 0)
                                {
                                    <div class="layui-input-block" style="margin:0;">
                                        审核中,提交时间@(checkInfo.CreateTime)

                                    </div>
                                }
                                else if (checkInfo.Status == 1)
                                {
                                    <div class="layui-input-block" style="margin:0;">
                                        审核成功,审核时间@(checkInfo.UpdateTime)
                                        <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="javascript:;" id="btn_release">发布最新版小程序</a>
                                    </div>
                                }


                            </div>
                            if (checkInfo.Status == 2)
                            {
                                <div class="layui-form-item">
                                    <label for="" class="layui-form-label">
                                        上传版本
                                    </label>
                                    <div class="layui-input-block" style="margin:0;">
                                        <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=@(_serverAppID)&pre_auth_code=@(_pre_auth_code)&redirect_uri=@(_redirect_uri)">更新并上传</a>

                                    </div>
                                </div>
                            }

                            if (checkInfo.Status == 2)
                            {
                                <div class="layui-form-item">
                                    <label for="" class="layui-form-label">
                                        获取体验版
                                    </label>
                                    <div class="layui-input-block" style="margin:0;">
                                        <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="javascript:void(0);" id="btn_getQrCode">获取体验</a>

                                    </div>
                                </div>
                            }
                            if (checkInfo.Status == 2)
                            {
                                <div class="layui-form-item">
                                    <label for="" class="layui-form-label">
                                        微信审核
                                    </label>
                                    <div class="layui-input-block" style="margin:0;">
                                        <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="javascript:void(0);" id="btn_submit">提交微信审核</a>
                                    </div>
                                </div>
                            }
                            if (checkInfo.Status == 0)
                            {
                                <div class="layui-form-item">
                                    <label for="" class="layui-form-label">
                                        获取结果
                                    </label>
                                    <div class="layui-input-block" style="margin:0;">
                                        <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="javascript:void(0);" id="btn_getResult">获取微信审核结果</a>
                                    </div>
                                </div>
                            }

                        }
                        else
                        {
                            /*如果版本不是最新，审核信息还是空，那么一定还没上传最新代码。(发布代码，会清空审核信息)*/
                            <div class="layui-form-item">
                                <label for="" class="layui-form-label">
                                    上传版本
                                </label>
                                <div class="layui-input-block" style="margin:0;">
                                    <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=@(_serverAppID)&pre_auth_code=@(_pre_auth_code)&redirect_uri=@(_redirect_uri)">更新并上传</a>

                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label for="" class="layui-form-label">
                                    获取体验版
                                </label>
                                <div class="layui-input-block" style="margin:0;">
                                    <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="javascript:void(0);" id="btn_getQrCode">获取体验</a>

                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="" class="layui-form-label">
                                    微信审核
                                </label>
                                <div class="layui-input-block" style="margin:0;">
                                    <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="javascript:void(0);" id="btn_submit">提交微信审核</a>
                                </div>
                                <div class="layui-form-mid layui-word-aux">
                                    <span class="x-red">小程序的标签，多个标签用空格分隔，标签不能多于10个，标签长度不超过20</span>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="" class="layui-form-label">
                                    获取结果
                                </label>
                                <div class="layui-input-block" style="margin:0;">
                                    <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="javascript:void(0);" id="btn_getResult">获取微信审核结果</a>
                                </div>
                            </div>
                        }





                    }
                    else
                    {
                        <div class="layui-form-item">
                            <label for="" class="layui-form-label">
                                版本信息
                            </label>
                            <div class="layui-input-block" style="margin:0;">
                                不需要更新,正在运行中
                            </div>
                        </div>
                    }
                    <div class="layui-form-item">
                        <label for="" class="layui-form-label">
                            重置
                        </label>
                        <div class="layui-input-block" style="margin:0;">
                            <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="javascript:void(0);" id="btn_reset">重新整个流程</a>
                        </div>
                        <div class="layui-form-mid layui-word-aux">
                            <span class="x-red">注意：有问题先找客服,不要随意点重置</span>
                        </div>
                    </div>


                </div>

            </div>
        </div>
    </div>
</div>
<script src="~/scripts/ShopApp/CheckVersion.js"></script>

<script>
    CheckVersionClass.Instance.Init();
</script>